package com.sumainfor.pc.epc.controller.housekeeper;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.epc.feign.Zfeign.ZpcMktFeign;
import com.sumainfor.pc.epc.service.HoDecoratePiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/housekeeper/HoDecoratePi")
public class HoDecoratePiController implements Serializable{

    @Autowired
    private HoDecoratePiService hoDecoratePiService;

    @Autowired
    private ZpcMktFeign zpcMktFeign;

    /**
     *服务管家新房验收列表待验收、已驳回、待上传图片
     */
    @GetMapping("/getHoDecoratePiList")
    public JsonResult getHoDecoratePiList(@RequestParam Map<String, Object> params, Pager pager) {
        System.out.println("params:"+params);
        List<Map<String,Object>> houIdList=new ArrayList<Map<String,Object>>();
        //是否有选择省市区条件
        if (!params.get("Province").toString().equals("")
                ||  !params.get("City").toString().equals("")
                ||  !params.get("District").toString().equals("")
                ||  !params.get("Street").toString().equals("")
                ||  !params.get("ComId").toString().equals("")
                ||  !params.get("BuilDing").toString().equals("")
                ||  !params.get("Room").toString().equals("")

        ){
            JsonResult comFeign=zpcMktFeign.getHouIdList(params);
            if (comFeign.get("errorCode").equals("0")) {
                houIdList=(List<Map<String,Object>>)comFeign.get("result");
                params.put("houIdList",houIdList);
            }
        }
        JsonResult result = new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout = hoDecoratePiService.getHoDecoratePiListCount(params);
        if (cout == 0) {
            return pageUtils.getJsonResult(new ArrayList<Map<String, Object>>(), params, cout);
        }
        List<Map<String, Object>> getCommunityList = hoDecoratePiService.getHoDecoratePiList(params);
        result = pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     *服务管家新房验收列表待验收、已驳回、待上传图片
     */
    @GetMapping("/getHoDecorateCount")
    public JsonResult getHoDecorateCount(@RequestParam Map<String, Object> params) {
        return hoDecoratePiService.getHoDecorateCount(params);
    }
    /**
     *租赁顾问签约的时候查询房源的装修计划预计完成时间
     */
    @GetMapping("/getHoDpiPredictTime")
    public JsonResult getHoDpiPredictTime(@RequestParam Map<String, Object> params) {
        return hoDecoratePiService.getHoDpiPredictTime(params);
    }

}
